package com.example.hosptialtag.controller;

import com.example.hosptialtag.pojo.Result;
import com.example.hosptialtag.pojo.Tag;
import com.example.hosptialtag.service.BindService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @Author liuyuhao&caiang
 * @Date 2022/2/21
 */

@Controller
public class BindController {

    @Autowired
    private BindService bindService;

    @RequestMapping(value = "/bindPage")
    public String bindPage(){
        return "bindPage";
    }

    @RequestMapping(value = "/createBind")//新建绑定（病人id——标签id）有限时间
    public String createBind(int bind_patient_id, int bind_tag_id, String bind_start_time, String bind_end_time,
                             int oid, int role, Model model) {
        return bindService.createBind(bind_patient_id, bind_tag_id, bind_start_time, bind_end_time, oid, role, model);
    }

    @RequestMapping(value = "/createBindForever")//新建绑定，1900到9999年默认为无限时间
    public String createBindForever(int bind_patient_id, int bind_tag_id, Model model) {
        return bindService.createBindForever(bind_patient_id, bind_tag_id, model);
    }

    @RequestMapping(value = "/updateBind")
    public String updateBind(int bind_id, String bind_start_time, String bind_end_time, int oid, int role, Model model){
        return bindService.updateBind(bind_id, bind_start_time, bind_end_time, oid, role, model);
    }

    @RequestMapping(value = "/deleteBindById")//根据bind_id删除
    public String deleteBindId(int bind_id, int oid, int role, Model model) {
        return bindService.deleteBindById(bind_id, oid, role, model);
    }

    @RequestMapping(value = "/deleteBindByTagIdAndPatientId")//根据标签id和病人id删除
    public String deleteBindByTagIdAndPatientId(int bind_patient_id, int bind_tag_id, int oid, int role, Model model){
        return bindService.deleteBindByTagIdAndPatientId(bind_patient_id, bind_tag_id, oid, role, model);
    }
    @RequestMapping(value = "/getBindById")//根据bind_id获取
    public String getBindById(int bind_id, Model model) {
        return bindService.getBindById(bind_id, model);
    }


    @RequestMapping(value = "/getBindByTagId")//根据bind_tag_id获取  并保证在期限内
    public String getBindByTagId(int bind_tag_id, Model model){
        return bindService.getBindByTagId(bind_tag_id);
    }

    @RequestMapping(value = "/getBindPageByPatientId")//点击病人详情，前往病人的标签页面
    public String getBindPageByPatientId(int bind_patient_id,Model model){
        return bindService.getBindPageByPatientId(bind_patient_id,model);
    }

    @RequestMapping(value = "/getBindPage")
    public String getBindPage(int bind_patient_id, int bind_tag_id,int oid, int role, Model model){
        return bindService.getBindPage(bind_patient_id, bind_tag_id, oid, role, model);
    }

    @RequestMapping(value = "/getBindPageByTagIdAndPatientId")
    public String getBindPageByTagIdAndPatientId(int bind_patient_id, int bind_tag_id, int oid, int role, Model model){
        return bindService.getBindPageByTagIdAndPatientId(bind_patient_id, bind_tag_id, oid, role, model);
    }
}
